#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

enum COLORS{
	BLACK = 2,
	WHITE = 0,
	GREY = 1
};

void dfs(int v, vector <vector <int> > &graph, vector <COLORS> &color, vector <int> &topsort, bool found_cycles) {
    color[v] = GREY;
    for (int to: graph[v]) {
        if (!color[to])
            dfs(to, graph, color, topsort, found_cycles);
        else if (color[to] == GREY) {
            found_cycles = 1;
        }
    }
    topsort.push_back(v);
    color[v] = BLACK;
}

void input(int &n, int &a, int &b, vector <vector <int> > &graph) {
	cin >> n >> a >> b;
	graph.resize(n * 2);
	while (a-- > 0) {
        int i, j;
        cin >> i >> j;
        --i, --j;
        graph[i + n].push_back(j);
    }
    while (b-- > 0) {
        int i, j;
        cin >> i >> j;
        --i, --j;
        graph[j].push_back(i + n);
        graph[i].push_back(j + n);
    }
    for (int i = 0; i < n; ++i) {
        graph[i].push_back(i + n);
    }
}

bool solve(int n, vector <vector <int> > &graph, vector <int> &x, vector <int> &y) {
	vector <COLORS> color(n * 2);
    vector <int> topsort;
    bool found_cycles = 0;
    for (int i = 0; i < n; ++i) {
        if (!color[i])
            dfs(i, graph, color, topsort, found_cycles);
    }
    reverse(topsort.begin(), topsort.end());
    for (int i = 0; i < n * 2; ++i) {
        if (topsort[i] >= n) {
            y[topsort[i] - n] = i;
        } else {
            x[topsort[i]] = i;
        }
    }
    return found_cycles;
}

void output(const vector <int> &x, const vector <int> &y) {
	for (int i = 0; i < x.size(); ++i) {
		cout << x[i] << ' ' << y[i] << endl;
	}
	return;
}

int main() {
    int n, a, b;
    vector <vector <int> > graph;
    input(n, a, b, graph);
    vector <int> x(n), y(n);
	if (solve(n, graph, x, y)) {
    	output(x, y);
	}
	else {
		cout << "Impossible";
	}
    return 0;
}